<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 进销存管理系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
    <style>
        body {
            background-color: #f5f5f5;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .login-form {
            width: 100%;
            max-width: 400px;
            padding: 15px;
            margin: auto;
        }
        .card {
            border-radius: 1rem;
            box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
        }
        .card-header {
            background-color: #343a40;
            color: white;
            border-radius: 1rem 1rem 0 0 !important;
            padding: 1rem;
        }
        .btn-primary {
            background-color: #343a40;
            border-color: #343a40;
        }
        .btn-primary:hover {
            background-color: #23272b;
            border-color: #23272b;
        }
    </style>
</head>
<body>
    <div class="login-form">
        <div class="card">
            <div class="card-header text-center">
                <h4 class="mb-0">进销存管理系统</h4>
            </div>
            <div class="card-body p-4">
                <!-- 错误消息 -->
                <div th:if="${param.error}" class="alert alert-danger" role="alert">
                    用户名或密码错误
                </div>
                <div th:if="${param.logout}" class="alert alert-success" role="alert">
                    您已成功退出登录
                </div>
                <div th:if="${success}" class="alert alert-success" role="alert">
                    <span th:text="${success}"></span>
                </div>
                <div th:if="${error}" class="alert alert-danger" role="alert">
                    <span th:text="${error}"></span>
                </div>
                
                <h5 class="card-title text-center mb-4">用户登录</h5>
                
                <form th:action="@{/login}" method="post">
                    <div class="mb-3">
                        <label for="username" class="form-label">用户名</label>
                        <div class="input-group">
                            <span class="input-group-text"><i class="bi bi-person"></i></span>
                            <input type="text" class="form-control" id="username" name="username" required autofocus>
                        </div>
                    </div>
                    <div class="mb-3">
                        <label for="password" class="form-label">密码</label>
                        <div class="input-group">
                            <span class="input-group-text"><i class="bi bi-lock"></i></span>
                            <input type="password" class="form-control" id="password" name="password" required>
                        </div>
                    </div>
                    <div class="mb-3 form-check">
                        <input type="checkbox" class="form-check-input" id="remember-me" name="remember-me">
                        <label class="form-check-label" for="remember-me">记住我</label>
                    </div>
                    <div class="d-grid gap-2">
                        <button type="submit" class="btn btn-primary">登录</button>
                    </div>
                </form>
                
                <div class="mt-3 text-center">
                    <p>还没有账号？<a th:href="@{/register}" class="text-decoration-none">立即注册</a></p>
                </div>
            </div>
        </div>
    </div>
</body>
</html> 